package ATM;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MenuJpanel extends JPanel implements ActionListener {
    private ATMJframe atmJframe;
    private JButton btnSave;
    private JButton btnGet;
    private JButton btnFind;


    private Icon buttonSave = Util.getimagesIcon("/images/buttonSave.jpg");
    private Icon buttonGet = Util.getimagesIcon("/images/buttonGet.jpg");
    private Icon buttonFind = Util.getimagesIcon("/images/buttonFind.jpg");

    public MenuJpanel(ATMJframe atmJframe) {
        this.atmJframe = atmJframe;
        this.setLayout(null);
        this.setOpaque(false);
        btnSave = new JButton("", buttonSave);
        btnSave.setBounds(200, 150, 140, 50);
        this.add(btnSave);
        btnSave.addActionListener(this);
        btnGet = new JButton("", buttonGet);
        btnGet.setBounds(200, 350, 140, 50);
        this.add(btnGet);
        btnGet.addActionListener(this);
        btnFind = new JButton("", buttonFind);
        btnFind.setBounds(200, 550, 140, 50);
        this.add(btnFind);
        btnFind.addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (btnSave == e.getSource()) {
            atmJframe.switchPanel("save");
        } else if (btnGet == e.getSource()) {
            atmJframe.switchPanel("get");
        } else if (btnFind == e.getSource()) {
            atmJframe.switchPanel("find");
        }
    }
}
